#version 120 
#extension GL_ARB_texture_rectangle : enable


uniform sampler2D positions;
uniform sampler2D infos;
uniform sampler2D pointSprite;

uniform float time;
uniform vec2 pointSize;

varying vec4 myPosition;
varying vec4 spriteColor;
varying vec4 myInfo;

uniform float alpha;

void main (){
	
	myPosition   = texture2D (positions,  gl_Vertex.xy);
	myInfo       = texture2D (infos,      gl_Vertex.xy);
	float angle  = time * myInfo.y;
	
	vec2 mySize = pointSize;
	
	if (myPosition.z > 1)
		mySize *= 3;
		
	gl_Position = gl_ModelViewProjectionMatrix * myPosition;
	vec2 offset = mySize * gl_Vertex.zw;
	offset = vec2(offset.x*cos(angle) - offset.y*sin(angle), offset.x*sin(angle) + offset.y*cos(angle));
	gl_Position.xy += offset;
	
	
	
	gl_TexCoord[0] = gl_MultiTexCoord0;
	
	
	//vec4 myValues = texture2DRect(infos, gl_Vertex.xy);
	//float myAlpha = clamp(1 - myValues.x / myValues.y,0,1);
	
	gl_FrontColor = gl_Color;	
	//gl_FrontColor.a *=  min(myAlpha + alpha,1);
}
